digraph {
node[fontname = "Fangsong"];
graph [splines=polyline];
D0 [shape=box, style=rounded, label="begin"];
{rank = sink; D1 [shape=box, style=rounded, label="end"];}
D4 [shape=box, label="int numStudents;"];
D6 [shape=box, label="printf(\"请输入学生人数: \");"];
D8 [shape=box, label="scanf(\"%d\", &numStudents);"];
D10 [shape=box, label="float** studentScores = (float**)malloc(numStudents * sizeof(float*));"];
D14 [shape=diamond, label="i < numStudents?"];
D15 [shape=box, label="int i = 0;"];
D16 [shape=box, label="i++"];
D19 [shape=box, label="studentScores[i] = (float*)malloc(NUM_COURSES * sizeof(float));"];
D21 [shape=box, label="int* studentIDs = (int*)malloc(numStudents * sizeof(int));"];
D23 [shape=box, label="float* totalScores = (float*)malloc(numStudents * sizeof(float));"];
D25 [shape=box, label="float* averageScores = (float*)malloc(numStudents * sizeof(float));"];
D29 [shape=diamond, label="i < numStudents?"];
D30 [shape=box, label="int i = 0;"];
D31 [shape=box, label="i++"];
D34 [shape=box, label="studentIDs[i] = i + 1;"];
D36 [shape=box, label="printf(\"请输入第%d位学生的成绩（依次为语文、数学、英语、程序设计）: \", studentIDs[i]);"];
D40 [shape=diamond, label="j < NUM_COURSES?"];
D41 [shape=box, label="int j = 0;"];
D42 [shape=box, label="j++"];
D45 [shape=box, label="scanf(\"%f\", &studentScores[i][j]);"];
D47 [shape=box, label="printf(\"\n班级统计信息:\n\");"];
D51 [shape=diamond, label="j < NUM_COURSES?"];
D52 [shape=box, label="int j = 0;"];
D53 [shape=box, label="j++"];
D56 [shape=box, label="float total = 0.0;"];
D58 [shape=box, label="float average = 0.0;"];
D62 [shape=diamond, label="i < numStudents?"];
D63 [shape=box, label="int i = 0;"];
D64 [shape=box, label="i++"];
D67 [shape=box, label="total += studentScores[i][j];"];
D69 [shape=box, label="average = total / numStudents;"];
D71 [shape=box, label="printf(\"课程 %d: 总分 = %.2f, 平均分 = %.2f\n\", j + 1, total, average);"];
D75 [shape=diamond, label="i < numStudents?"];
D76 [shape=box, label="int i = 0;"];
D77 [shape=box, label="i++"];
D80 [shape=box, label="calculateTotalAverage(studentScores[i], NUM_COURSES, &totalScores[i], &averageScores[i]);"];
D82 [shape=box, label="sortStudents(studentScores, studentIDs, totalScores, numStudents);"];
D84 [shape=box, label="printf(\"\n学生统计信息（按总分降序排序）:\n\");"];
D86 [shape=box, label="printf(\"%-17s%-17s%-17s%-17s%-19s%-17s%-17s\n\", \"学号\", \"语文\", \"数学\", \"英语\", \"程序设计\", \"总分\", \"平均分\");"];
D90 [shape=diamond, label="i < numStudents?"];
D91 [shape=box, label="int i = 0;"];
D92 [shape=box, label="i++"];
D95 [shape=box, label="printf(\"%-15d%-15.2f%-15.2f%-15.2f%-15.2f%-15.2f%-15.2f\n\", studentIDs[i], studentScores[i][0], studentScores[i][1], studentScores[i][2], studentScores[i][3], totalScores[i], averageScores[i]);"];
D99 [shape=diamond, label="i < numStudents?"];
D100 [shape=box, label="int i = 0;"];
D101 [shape=box, label="i++"];
D104 [shape=box, label="free(studentScores[i]);"];
D106 [shape=box, label="free(studentScores);"];
D108 [shape=box, label="free(studentIDs);"];
D110 [shape=box, label="free(totalScores);"];
D112 [shape=box, label="free(averageScores);"];
D114 [shape=box, label="return 0;"];
D4 -> D6;
D6 -> D8;
D8 -> D10;
D10 -> D15;
D14:e -> D21:n [xlabel=N];
D15 -> D14;
D19 -> D16;
D16 -> D14;
D21 -> D23;
D14:s -> D19:n [xlabel=Y];
D23 -> D25;
D25 -> D30;
D29:e -> D47:n [xlabel=N];
D30 -> D29;
D34 -> D36;
D31 -> D29;
D36 -> D41;
D40:e -> D31:n [xlabel=N];
D41 -> D40;
D45 -> D42;
D42 -> D40;
D47 -> D52;
D40:s -> D45:n [xlabel=Y];
D29:s -> D34:n [xlabel=Y];
D51:e -> D76:n [xlabel=N];
D52 -> D51;
D56 -> D58;
D53 -> D51;
D58 -> D63;
D62:e -> D69:n [xlabel=N];
D63 -> D62;
D67 -> D64;
D64 -> D62;
D69 -> D71;
D62:s -> D67:n [xlabel=Y];
D71 -> D53;
D75:e -> D82:n [xlabel=N];
D51:s -> D56:n [xlabel=Y];
D76 -> D75;
D80 -> D77;
D77 -> D75;
D82 -> D84;
D75:s -> D80:n [xlabel=Y];
D84 -> D86;
D86 -> D91;
D90:e -> D100:n [xlabel=N];
D91 -> D90;
D95 -> D92;
D92 -> D90;
D99:e -> D106:n [xlabel=N];
D90:s -> D95:n [xlabel=Y];
D100 -> D99;
D104 -> D101;
D101 -> D99;
D106 -> D108;
D99:s -> D104:n [xlabel=Y];
D108 -> D110;
D110 -> D112;
D112 -> D114;
D114 -> D1;
D0 -> D4;
}
